/**
 * Created by malingling on 15-11-30.
 */
app.controller('MenuCtrl', function ($scope, $location) {
    $scope.people = ['赵大', '钱二', '张三', '李四', '王五', '赵六'];
    var informs = localStorage.getItem ('informs');
    $scope.informs = JSON.parse(informs);

    var count = order_people($scope.informs);
    $scope.people_count = count.count ;

    $scope.names = none_order_people(count.people,$scope.people)

    $scope.no_people_count = $scope.people.length - $scope.people_count;
    var all_sum = count_sum($scope.informs);
    $scope.sum = all_sum.toFixed(2);
    for(key in count.people){
        console.log(count.people[key] )
    }

})

function order_people(informs){
    var order_peoples = {};
    var people_count = 0;
    informs.forEach(function(inform){
        if(order_peoples[inform.person] == undefined )
        {
            order_peoples[inform.person] = inform.person;
            people_count += 1;
        }

    })
    return {count:people_count,people:order_peoples};

}
var sum = 0;
function count_sum(informs){

    informs.forEach(function(inform){
        sum += parseFloat(inform.combo_price);

    })
    return sum;

}
function none_order_people(names,persons){
    var none_order_person = [];
    persons.forEach(function(inform){
        if(names[inform] == undefined ){
            none_order_person.push(inform);
        }
    })
    return none_order_person;
    console.log()
}

